package top.yuyufeng.ticketassistant.service;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.yuyufeng.ticketassistant.orm.ServiceTrainDTO;
import top.yuyufeng.ticketassistant.remote.TrainRemote;

import java.util.List;

/**
 * created by yuyufeng on 2018/1/16.
 */
public class TrainService {
    private final Logger LOG = LoggerFactory.getLogger(this.getClass());
    private TrainRemote trainRemote = new TrainRemote();

    public List<ServiceTrainDTO> SearchTrainList(String begin, String end, String trainDate) throws Exception {
        List<ServiceTrainDTO> list;
        list = trainRemote.queryTrainListFromRemote(begin, end, trainDate);
        if (list == null) return null;
        LOG.info("查询到车次数量：" + list.size());
        return list;
    }





    public static void main(String[] args) throws Exception {
        TrainService trainService = new TrainService();
        List<ServiceTrainDTO> list = trainService.SearchTrainList("杭州", "厦门", "2018-02-01");
        for (ServiceTrainDTO serviceTrainDTO : list) {
            System.out.println(serviceTrainDTO);
        }
    }
}
